<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    h1{
        text-align: center;
    }
    form{
        width: 500px;
        margin: auto;
        border: 1px solid red;
    }
    form div{
        width: 100%;
        margin: 20px 30%;
    }
    button{
        
        width: 100px;
        height: 30px;
        margin: 10px 42%;
        background-color: aquamarine;
        
    }
</style>
<body>
    <h1>用户登录案例</h1>
    <form action="">
       <div>
        <label for="op">账号</label>
        <input  id= "op"type="text" placeholder="请输入账号">
       </div>
       <div>
        <label for="pa">密码</label>
        <input  id= "pa" type="password" placeholder="请输入密码">
       </div>
       <button id="kl">登录</button>
    </form>
</body>
</html>
<script>
    // 标签节点
    var userName = document.getElementById('op')//账号
    var pass = document.getElementById('pa')//密码
    var bth = document.getElementById('kl')//登录
    //点击事件
    bth.onclick = function(){
        var userValu = userName.value//账号值
        var passValu = pass.value//密码值
        if(userValu == 'admin' && passValu == '123'){
            alert('恭喜登录成功')
        }else{
            alert('账号与密码错误')
        }
    }
</script>